﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using InterLinq.Test.Views;
using Sebarf.Core.Interfaces;
using Sebastof.Services.Interfaces;

namespace InterLinq.Test.UI {
	/// <summary>
	/// Interaction logic for SumByOrderPositionForm.xaml
	/// </summary>
	public partial class SumByOrderPositionForm : UserControl {
		#region public properties

		public IServiceLocatorService CorespondingDataContext { get; set; }

		#endregion

		#region public methods

		public SumByOrderPositionForm(IList<SumByOrderPositionsView> view, IServiceLocatorService corespondingContext) {
			InitializeComponent();
			m_view.ItemsSource = view;
			if (corespondingContext == null) {
				m_submitChangesButton.Visibility = Visibility.Collapsed;
			}
			CorespondingDataContext = corespondingContext;
		}

		#endregion

		#region private methods

		private void OnSubmitChanges(object sender, RoutedEventArgs e) {
			CorespondingDataContext.GetRegisteredService<IChangeHandlerService>().SubmitChanges();
		}

		#endregion
	}
}